home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Resources / Developers / XAMPP 1.5.4 / Windows installer / xampp-win32-1.5.4-installer.exe / xampp / phpMyAdmin / libraries / dbg / profiling.php next >
Encoding:
PHP Script  |  2006-01-17  |  4.7 KB  |  106 lines

  1. <?php
  2. /* $Id: profiling.php,v 2.10 2006/01/17 17:03:02 cybot_tm Exp $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4. /**
  5.  * holds function for dumping profiling data
  6.  * 
  7.  * allways use $GLOBALS here, as this script is included by footer.inc.hp
  8.  * which can also be included from inside a function
  9.  */
  10.  
  11. if ( ! empty( $GLOBALS['DBG'] ) 
  12.   && $GLOBALS['cfg']['DBG']['profile']['enable'] ) {
  13.  
  14.     /**
  15.      * Displays profiling results when called
  16.      * WARNING: this function is SLOW
  17.      */
  18.     function dbg_dump_profiling_results() {
  19.         /* Applies to the original 'dbg_dump_profiling_results' function,
  20.          * sourced from http://dd.cron.ru/dbg/download.php?h=prof_sample2
  21.          * Copyright (c) 2002. Dmitri Dmitrienko
  22.          * LICENCE: This source file is subject to Mozilla Public License (MPL)
  23.          * AUTHOR: Dmitri Dmitrienko <dd@cron.ru>
  24.          */
  25.         dbg_get_profiler_results( $dbg_prof_results = '' );
  26.         $cwdlen =  strlen(getcwd()); // gma added var, $cwdlen =  strlen(getcwd());
  27.         echo '<br /><table xml:lang="en" dir="ltr" width="1000" cellspacing="0" cellpadding="2" style="font:8pt courier">' . "\n" .
  28.             '<thead>' . "\n";
  29.         // gma added "$tr ="
  30.         $tr = '<tr>' . "\n" .
  31.             '<th>' . $GLOBALS['strDBGModule'] . '</th>' . "\n" .
  32.             '<th>' . $GLOBALS['strDBGLine'] . '</th>' . "\n" .
  33.             '<th>' . $GLOBALS['strDBGHits'] . '</th>' . "\n" .
  34.             '<th>' . $GLOBALS['strDBGTimePerHitMs'] . '</th>' . "\n" .
  35.             '<th>' . $GLOBALS['strDBGTotalTimeMs'] . '</th>' . "\n" .
  36.             '<th>' . $GLOBALS['strDBGMinTimeMs'] . '</th>' . "\n" .
  37.             '<th>' . $GLOBALS['strDBGMaxTimeMs'] . '</th>' . "\n" .
  38.             '<th>' . $GLOBALS['strDBGContextID'] . '</th>' . "\n" .
  39.             '<th>' . $GLOBALS['strDBGContext'] . '</th>' . "\n" .
  40.             '</tr>' . "\n";  // gma change "." to ";"
  41.         echo $tr.'</thead><tbody style="vertical-align: top">' . "\n";
  42.         $lines      = 0; // gma added "echo $tr." and "$lines = 0;"
  43.         $ctx_name   = '';
  44.         $mod_name   = '';
  45.         $ctx_id     = '';
  46.         $odd_row    = true;
  47.         foreach ( $dbg_prof_results['line_no'] as $idx => $line_no ) {
  48.             dbg_get_module_name( $dbg_prof_results['mod_no'][$idx], $mod_name );
  49.  
  50.             //if (strpos("!".$mod_name, 'dbg.php') > 0) continue;
  51.  
  52.             $time_sum = $dbg_prof_results['tm_sum'][$idx] * 1000;
  53.             $time_avg_hit = $time_sum / $dbg_prof_results['hit_count'][$idx];
  54.  
  55.             $time_sum = sprintf( '%.3f', $time_sum );
  56.             $time_avg_hit = sprintf('%.3f', $time_avg_hit);
  57.             $time_min = sprintf( '%.3f', $dbg_prof_results['tm_min'][$idx] * 1000 );
  58.             $time_max = sprintf( '%.3f', $dbg_prof_results['tm_max'][$idx] * 1000 );
  59.             dbg_get_source_context( $dbg_prof_results['mod_no'][$idx],
  60.                 $line_no, $ctx_id );
  61.  
  62.             // use a default context name if needed
  63.             if ( dbg_get_context_name( $ctx_id, $ctx_name )
  64.                     && strlen($ctx_name) == 0 ) {
  65.                 $ctx_name = "::main";
  66.             }
  67.  
  68.             if ( $time_avg_hit > $GLOBALS['cfg']['DBG']['profile']['threshold'] ) {
  69.                 echo '<tr class="' . $odd_row ? 'odd' : 'even' . '">' .
  70.                     // gma changed "$mod_name" to "substr($mod_name, $cwdlen+1)"
  71.                     '<td>' . substr($mod_name, $cwdlen+1) . '</td>' .
  72.                     '<td>' . $line_no . '</td>' .
  73.                     '<td>' . $dbg_prof_results['hit_count'][$idx] . '</td>' .
  74.                     '<td>' . $time_avg_hit . '</td>' .
  75.                     '<td>' . $time_sum . '</td>' .
  76.                     '<td>' . $time_min . '</td>' .
  77.                     '<td>' . $time_max . '</td>' .
  78.                     '<td>' . $ctx_id . '</td>' .
  79.                     '<td>' . $ctx_name . '</td>' .
  80.                     '</tr>' . "\n";
  81.                 
  82.                 // gma added line. Repeats the header every x lines.
  83.                 if ( $lines === 19 ) {
  84.                     $odd_row    = true;
  85.                     $lines      = 0;
  86.                     echo $tr;
  87.                 } else {
  88.                     $odd_row    = ! $odd_row;
  89.                     $lines++;
  90.                 }
  91.             }
  92.         }
  93.         echo '</tbody></table>';
  94.     }
  95. }
  96. /*  gma ... Developer Notes
  97. These two scriptlets can be used as On/Off buttons in your browsers, add to links. 
  98. ON:
  99. javascript: document.cookie = 'DBGSESSID=' + escape('1;d=1,p=1') + '; path=/'; document.execCommand('refresh'); 
  100. or ... 
  101. javascript: document.cookie = 'DBGSESSID=' + escape('1;d=0,p=1') + '; path=/'; document.execCommand('refresh');
  102. OFF:
  103. javascript: document.cookie = 'DBGSESSID=' + escape('1;d=0,p=0') + '; path=/'; document.execCommand('refresh');
  104. */
  105. ?>
  106.